package com.hehe.controller;

import com.hehe.Dao.Select_Mapper;
import com.hehe.Dao.Update_Mapper;
import com.hehe.POJO.Tb_sql_test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping(value = "/sort")
public class Sort_id {

    @Value("${spring.datasource.url}")
    private String age;

    @Autowired(required = false)
    private Select_Mapper select_mapper;

    @Autowired(required = false)
    private Update_Mapper update_mapper;

    @Autowired
    private JdbcTemplate jdbcTemplate;


    @GetMapping(value = "/sort_id")
    @ResponseBody
    public String sort_id(Model model) {
        List<Integer> id_list = select_mapper.get_id_list();
        int max_num = id_list.size();
        for (int old_id : id_list) {
            max_num++;
            update_mapper.update_sort_id(old_id, max_num);
        }
        return "1111111111";
    }


//    @GetMapping(value="/aaa"  )
//    public String qqqqqq(Model model, HttpServletRequest request, Integer id, String sql ){
//        return "index/index.html";
//    }
//    @GetMapping(value="/bbb"  )
//    public String qqqvvv(Model model, HttpServletRequest request, Integer id, String sql ){
//        return "index/index.html";
//    }


}




